package com.xgk.boot.module.core.controller.admin.truck;

import com.xgk.boot.framework.common.pojo.CommonResult;
import com.xgk.boot.framework.common.pojo.PageResult;
import com.xgk.boot.framework.common.util.object.BeanUtils;
import com.xgk.boot.module.core.controller.admin.truck.vo.ApiLogPageReqVO;
import com.xgk.boot.module.core.controller.admin.truck.vo.ApiLogRespVO;
import com.xgk.boot.module.core.controller.admin.truck.vo.OrderLogPageReqVO;
import com.xgk.boot.module.core.controller.admin.truck.vo.OrderLogRespVO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrderApiLogDO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrderLogDO;
import com.xgk.boot.module.core.dal.iservice.truck.TruckOrderApiLogService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.xgk.boot.framework.common.pojo.CommonResult.success;

@RestController
@RequestMapping("/system/truck-log")
public class OrderLogController {

    @Resource
    private TruckOrderApiLogService truckOrderApiLogService;

    @GetMapping("/api-page")
    @Operation(summary = "查看订单API请求日志分页列表")
    public CommonResult<PageResult<ApiLogRespVO>> pageApiLog(@Valid ApiLogPageReqVO pageReqVO) {
        PageResult<TruckOrderApiLogDO> pageResult = truckOrderApiLogService.getApiLogPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, ApiLogRespVO.class));
    }

    @GetMapping("/order-page")
    @Operation(summary = "查看订单操作日志分页列表")
    public CommonResult<PageResult<OrderLogRespVO>> pageOrderLog(@Valid OrderLogPageReqVO pageReqVO) {
        PageResult<TruckOrderLogDO> pageResult = truckOrderApiLogService.getOrderLogPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, OrderLogRespVO.class));
    }
}
